package com.sun.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;

/**
 * @author SunRui
 * @description TODO
 * @date 2024/9/12 15:14
 */
public class JdbcConfig {
    @Value("${driver}")
    private String JDBCCONFIG_DRIVER;
    @Value("${url}")
    private String JDBCCONFIG_URL;
    @Value("${user}")
    private String JDBCCONFIG_USERNAME;
    @Value("${password}")
    private String JDBCCONFIG_PASSWORD;

    @Bean
    public DataSource dataSource(){
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setDriverClassName(JDBCCONFIG_DRIVER);
        dataSource.setUrl(JDBCCONFIG_URL);
        dataSource.setUsername(JDBCCONFIG_USERNAME);
        dataSource.setPassword(JDBCCONFIG_PASSWORD);
        return dataSource;
    }
}
